<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>网站篡改轮播调试页面</title>
    <script src="http://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
    <style type="text/css">
        * {
            margin: 0px;
            padding: 0px;
        }

        .div {
            height: 80px;
            border-bottom: 3px solid #ccc;
        }
    </style>
</head>
<div>
    <input class="action" type="button" id="getWebsiteList" value=" 查询网站信息查询接口 "/>
    <input name="action_choose" data-id="getWebsiteList" type="checkbox" checked="checked" value="1"/>
</div>
<div>
    <input class="action" type="button" id="getAlteredList" value=" 查询篡改信息查询接口 "/>
    <input name="action_choose" data-id="getAlteredList" type="checkbox" checked="checked" value="1"/>
</div>
<div>
    <input class="action" type="button" id="updateAlteredData" value=" 删除记录接口 "/>
    <input name="action_choose" data-id="updateAlteredData" type="checkbox" checked="checked" value="1"/>
</div>

<br/>
<input type="button" id="clickAll" value=" 选中全部发送 "/>

<script type="text/javascript">

    document.cookie = "key=escape('sssssss')";

    $(document).ready(function () {
        var wsurl = "ws://192.168.3.222:9507/";
        console.log(wsurl);
        var websocket = new WebSocket(wsurl);
        websocket.onopen = function (evt) {
            console.log('Server:  打开WebSocket连接');
        };

        websocket.onclose = function (evt) {
            console.log('Server:  关闭WebSocket连接');
        };

        websocket.onmessage = function (evt) {
            var res = JSON.parse(evt.data);
            console.log('Server:  收到消息(来自：' + res.action.name + '请求)');
            console.log(res);
        };

        websocket.onerror = function (evt) {
            console.log('Server:  出现错误');
            console.log(evt.data);
        }

        function doSend(msg) {
            console.log('Client: 发送消息  ' + msg);
            websocket.send(msg);
        }

        $("#getWebsiteList").click(function () {
            
            var msg = {
                action: {
                    name:$(this).attr('id'),
//                    debug: true,
                    addTimer: 3000,
                    limit: 1
                }

            };
            
            doSend(JSON.stringify(msg));
        });

        $("#getAlteredList").click(function () {

            var msg = {
                action: {
                    name:$(this).attr('id'),
//                    debug: true,
                    addTimer: 3000,
                    limit: 1
                }
            };
            doSend(JSON.stringify(msg));
        });
        $("#updateAlteredData").click(function () {

            var msg = {
                action: {
                    name:$(this).attr('id'),
                    id: [1,2,'3'],
                    limit: 1
                }
            };
            doSend(JSON.stringify(msg));
        });


        $("#clickAll").click(function () {
            console.log('clickAll');
            $.each($('input[type=checkbox]:checked'), function (index, ele) {
                $('#' + $(ele).data('id')).click();
            });
        });

    });
</script>

</body>
</html>
